package com.kotlinvben.repository

import com.kotlinvben.entity.User
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.JpaSpecificationExecutor
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository

@Repository
interface UserRepository : JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
    @Modifying
    @Query("UPDATE User u SET u.deleted = true WHERE u.id = :id")
    fun softDelete(@Param("id") id: Long)
    fun findByUsername(username: String): User?
}